package leetcode.code2299;

import java.util.HashSet;
import java.util.Set;

public class Solution {

	public boolean strongPasswordCheckerII(String password) {
		if (password.length() < 8) {
			return false;
		}
		boolean c2 = false, c3 = false, c4 = false, c5 = false;
		Set<Character> set = new HashSet<>();
		for (char c : "!@#$%^&*()-+".toCharArray()) {
			set.add(c);
		}
		char last = ' ';
		for (char c : password.toCharArray()) {
			if (Character.isLowerCase(c)) {
				c2 = true;
			} else if (Character.isUpperCase(c)) {
				c3 = true;
			} else if (Character.isDigit(c)) {
				c4 = true;
			} else if (set.contains(c)) {
				c5 = true;
			}
			if (c == last) {
				return false;
			}
			last = c;
		}
		return c2 && c3 && c4 && c5;
	}
}
